﻿@page

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>AjaxTest</title>
    <link href="/common/common.css" rel="stylesheet" />
    <script src="/common/jquery-1.10.2.min.js"></script>
    <script src="/common/common.js"></script>
    <style>
        html {
            padding: 30px;
        }
    </style>
    <script>
        function log(msg) {
            $("#log").val(new Date() + "\r\n" + msg.toJsonString() + "\r\n\r\n" + $("#log").val());
        }

        $(document).ready(function () {
            $("#PostForm").click(function () {
                $.postForm("api/ajaxtest/PostForm", { arg1: $("#arg1").val(), arg2: $("#arg2").val() }, function (data) { log(data); })
            });

            $("#PostJson").click(function () {
                $.postJson("api/ajaxtest/PostJson", { arg1: $("#arg1").val(), arg2: $("#arg2").val() }, function (data) { log(data); });
            });

            $("#PostText").click(function () {
                var data = { arg1: $("#arg1").val(), arg2: $("#arg2").val() };
                $.postText("api/ajaxtest/PostText", data.toJsonString(), function (data) { log(data); });
            });

            $("#PostNull").click(function () {
                $.postNull("api/ajaxtest/PostNull", function (data) { log(data); });
            });
        });
    </script>
</head>
<body bgcolor="#cccccc">
    <h3>AjaxTest</h3>
    <hr />
    arg1：<input id="arg1" value="value1" />
    arg2：<input id="arg2" value="value2" />
    <button id="PostForm">PostForm</button>
    <button id="PostJson">PostJson</button>
    <button id="PostText">PostText</button>
    <button id="PostNull">PostNull</button>
    <hr />
    日志：<br />
    <textarea id="log" class="width700px height300px"></textarea>
</body>
</html>